<?php
namespace Profile\Controller;
use Profile\Controller\BaseController;
class DingdanController extends BaseController {
	private $tbl;
	public function _initialize(){
		$this->tbl='dingdan';
		$this->model=D($this->tbl);
		parent::_initialize();
	}
	public function index(){
		$id=$_SESSION['user']['id'];
		//var_dump($id);exit;
		parent::index($this->tbl,"uid",$id);
	}
	public function	view(){
		$id=I('get.id');//获取id
	}
	public function show(){//显示
		$dnum=I('get.dnum');
		//var_dump($dnum);
		$sql="select * from dingdandet where dnum='{$dnum}'";
		$res=M()->query($sql);
		$this->assign("list",$res);
		//var_dump($res);exit;
		$this->display();
	}
	public function mod(){//修改界面
		$sql="select * from videotype";
		$data1=M()->query($sql);
		$this->assign("idlist",$data1);
		 parent::mod($this->tbl,"id");
	}
	public function update(){//修改
		parent::update($this->tbl,"pic");
	}
	public function delete(){//删除
		parent::delete($this->tbl,"id","pic");
	}
	public function form(){//添加界面
		$sql="select * from videotype";
		$data1=M()->query($sql);
		$this->assign("idlist",$data1);
		parent::form($this->tbl);
	}
	public function add(){//添加
			$this->model=D($this->tbl);
			$data=I('post.');
			$data['address']=parent::uploadWfile("address");
			$data['pic']=parent::uploadfile('pic');
			
			//var_dump($data);exit;
			if($this->model->create($data)){
				$this->model->add();
				$position="index";
				//echo $position;
				$this->success('增加成功！',U($position));
			}else{
				$this->error($this->model->getError());
				$this->error("增加失败！",U($position));
			}
	}
	public function search(){
		parent::search($this->tbl,"videoname","videoname");
	}
}